package com.atrix.CinemaView.service.impl;

import com.atrix.CinemaView.dao.FileDao;
import com.atrix.CinemaView.pojo.dto.VideoStreamData;
import com.atrix.CinemaView.pojo.dto.info.VideoInfo;
import com.atrix.CinemaView.exception.ParamErrorException;
import com.atrix.CinemaView.pojo.FileObj;
import com.atrix.CinemaView.service.VideoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class VideoServiceImpl implements VideoService {
    
    @Autowired
    FileDao fileDao;
    
    @Override
    public VideoStreamData getVideo(Integer containerIndex, Integer index) {
        if (index == null || containerIndex == null) {
            throw new ParamErrorException();
        }
        FileObj fileObj = fileDao.getVideo(containerIndex, index);
        return new VideoStreamData(fileObj);
    }
    
    @Override
    public List<VideoInfo> getVideoInfo() {
        return fileDao.getVideoInfoList();
    }
}
